﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Text;
using BF.Membership;
using BF.Membership.MembershipEF;
namespace BF.Membership.DAL
{
    public class MembershipUserInfoDAL
    {

        private WSJD_aspnetdbEntities entity;

        public MembershipUserInfoDAL()
        {
            entity = BF.Membership.Common.PubSysCommon.GetDBEntities;
        }
       
        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetList(string strWhere)
        //{
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("select sProvinceCode,sProvinceName,sCityCode,sCityName,sCountyCode,sCountyName,sTownCode,sTownName,sVillageCode,sVillageName,iAreaLevel,sAreaCode,sAreaName,UserID,sCode,sMembershipName,sUserName,sNetCode,sNetName,iUserType,sMemo ");
        //    strSql.Append(" FROM sysMembership_UserInfo ");
        //    if (strWhere.Trim() != "")
        //    {
        //        strSql.Append(" where " + strWhere);
        //    }
        //    Database db = DatabaseFactory.CreateDatabase();
        //    return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        //}

     
        /// <summary>
        /// 获取数据列表
        /// </summary>
       
        /// <returns></returns>
        public List<aspnet_Users> GetListArray(string userName, int page, int pageSize)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return entity.aspnet_Users.OrderBy(p => p.UserId).Skip(page * pageSize).Take(pageSize).ToList<aspnet_Users>();

            }
            else
            {
                return entity.aspnet_Users.Where(p => p.UserName.Contains(userName)).OrderBy(p => p.UserId).Skip(page).Take(pageSize).ToList<aspnet_Users>();
            }
        }

        public int GetListArrayCount(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return entity.aspnet_Users.Count();
            }
            else
            {
                return entity.aspnet_Users.Where(p => p.UserName.Contains(userName)).Count();
            }
        }


       
    }
}
